<template>
    <van-sticky>
        <van-nav-bar title="分类" />
    </van-sticky>

    <div class="type">
        <div class="list">
            <div class="item" v-for="item in TypeList" :key="item.id">
                <router-link :to="{path:'/product',query:{typeid:item.id}}">
                    <div class="thumb">
                        <img :src="item.thumb_text" />
                    </div>
                    <div class="name">{{ item.name }}</div>
                </router-link>
            </div>

            <van-back-top :bottom="'80'" />
        </div>
    </div>
</template>

<script setup>
const { proxy } = getCurrentInstance();

const TypeList = ref([]);

onBeforeMount(() =>
{
    GetTypeData();
})

const GetTypeData = async () =>
{
    let result = await proxy.$http.post({
        url:'product/type'
    })

    if(result.code === 1)
    {
        TypeList.value = result.data;
    }else
    {
        proxy.$fail(result.msg);
    }
}

</script>

<style scoped>
@import url('/assets/css/ProductType.css');
</style>